{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <!-- Panel Other -->
    <div class="ibox float-e-margins">
        <div class="ibox-title">
            <h5>普通用户列表</h5>
            <div class="ibox-tools">
                <a class="collapse-link">
                    <i class="fa fa-chevron-up"></i>
                </a>
            </div>
        </div>
        <div class="ibox-content">
            <!--搜索框开始-->           
            <div class="row">
                <div class="col-sm-12">   
                    <div  class="col-sm-3">
                        <div class="input-group" >
                            <a href="{:url('uUserAdd')}">
                                <button class="btn btn-outline btn-primary" type="button">
                                    <i class="fa fa-plus"></i> 添加用户
                                </button>
                            </a>
                            <!--<button  class="btn btn-outline btn-danger" href="javascript:;" data-toggle="dropdown">-->
                                <!--<i class="fa fa-wrench"></i> 批量操作 <span class="caret"></span>-->
                            <!--</button>-->
                            <!--<ul class="dropdown-menu animated fadeInDown" role="menu">-->
                                <!--<li><a href="javascript:;" class="layuiBtn" id="empty" data-type="reload"><i class="fa fa-retweet"></i> 重置搜索框 </a></li>-->
                                <!--<li><a href="javascript:;" class="layuiBtn" data-type="getCheckData"><i class="fa fa-trash-o"></i> 批量删除 </a></li>-->
                                <!--<li><a  href="javascript:;" class="layuiBtn" data-type="usingAll" id="onAll"><i class="fa fa-check-circle"></i> 批量启用</a></li>-->
                                <!--<li><a  href="javascript:;" class="layuiBtn" data-type="forbiddenAll" id="offAll"><i class="fa fa-ban"></i> 批量禁用</a></li>-->
                                <!--<li><a  href="javascript:;" class="layuiBtn" data-type="excelAll" id="excel"><i class="fa fa-print"></i> 导出Excel</a></li>-->
                            <!--</ul>-->
                        </div>
                    </div>
                    <div class="col-sm-9">
                        <form id="layuiForm">
                            <!--<div class="col-sm-5">-->
                                <!--<div class="input-group" >-->
                                    <!--<input type="text"  name="start" onclick="laydate({istime: true,format: 'YYYY-MM-DD hh:mm'})" class="form-control layer-date search" placeholder="开始日期" />-->
                                    <!--<span class="input-group-addon">到</span>-->
                                    <!--<input type="text"  name="end" onclick="laydate({istime: true,format: 'YYYY-MM-DD hh:mm'})"  class="form-control layer-date search" placeholder="结束日期" />-->
                                <!--</div>-->
                            <!--</div>-->
                            <div class="col-sm-4">
                                <div class="input-group" >
                                    <input type="text" id="key" class="form-control search" name="key" value="" width="300px" placeholder="输入昵称或手机号"/>
                                    <span class="input-group-btn">
                                        <a  class="btn btn-primary layuiBtn" data-type="reload"><i class="fa fa-search"></i> 搜索</a>
                                    </span>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
            <!--搜索框结束-->
            <div class="hr-line-dashed"></div>

            <div class="example-wrap">
                <div class="example">
                    <table class="layui-hide" id="test" lay-filter="demo"></table>
                </div>
            </div>
            <!-- End Example Pagination -->
        </div>
    </div>
</div>
<!-- End Panel Other -->
</div>
{include file="public/footer" /}
<script>
        layui.use('table', function () {
            var table = layui.table
            , form = layui.form;
        table.render({
            elem: '#test'
            , url: '{:url("Uuser/index")}'
            , page: true
            , even: false //开启隔行背景
            , size: 'lg' //sm小尺寸的表格 lg大尺寸
            // ,width:100
            , cellMinWidth: 80
            , limits: [5, 10, 15, 20, 25, 30]
            , limit: "{:config('pages')}"
            , text: {
                none: '暂无数据' //默认：无数据。注：该属性为 layui 2.2.5 开始新增
            }
            , loading: true
            , id: 'testReload'
            , cols: [[
                {type: 'checkbox', fixed: 'left',}
                , {type:'numbers', width: 60, title: '序号'}
                , {field: 'user_id', width: 60, title: 'ID', sort: false, align: 'center'}
                , {field: 'user_phone', width: 60, title: '手机号', sort: false, align: 'center'}
                , {field: 'user_username', width: 130, title: '昵称', align: 'center'}
                , {field: 'user_attestation', width: 70, title: '认证状态', align: 'center', templet:'#attestationTpl'}
                , {field: 'mechanism_name', width: 130, title: '所属机构', align: 'center'}
                , {field: 'user_me_content', width: 130, title: '个人介绍', align: 'center'}
                , {field: 'user_number', width: 100, title: '志愿者编号', align: 'center'}
                , {field: 'last_login_time', width: '', title: '最后登录时间', sort: false, align: 'center'}
                , {field: 'user_status',fixed: 'right', width: 100, title: '启用/停用',sort: false, align: 'center', templet: '#staBar'}
                , {fixed: 'right', width: 240, title: '操作', align: 'center', toolbar: '#opeBar'}
            ]]
            ,done: function (res, curr, count) {
                $.each(res.data,function(index,item){
                    $('#view_'+item['id']).viewer({
                        url: 'data-original',
                    });
                });
            }
        });
        //监听状态开关操作
        form.on('switch(OnOff)', function (obj) {
            // layer.tips(this.value + ' ' + this.name + '：'+ obj.elem.checked, obj.othis);
            if(obj.elem.checked == true){
                var num = 1;
            }else{
                var num = 2;
            }
            //用户状态
            wk.status(this.value,num, '{:url("uUserStatus")}');
        });
        //搜索表格重载
        var $ = layui.$, active = {
            reload: function () {
                //执行重载
                table.reload('testReload', {
                    page: {
                        curr: 1 //重新从第 1 页开始
                    }
                    , where:$('#layuiForm').parseForm()
                });
            }
            ,getCheckData: function(){
                //批量删除
                wk.batchDel(getIds(),"{:url('batchDelUser')}");
            }
            ,forbiddenAll: function(){
                //批量禁用
                wk.batchForbidden(getIds(),2,"{:url('forbiddenAdmin')}");
            }
            ,usingAll: function(){
                //批量启用
                wk.usingAll(getIds(),1,"{:url('usingAdmin')}");
            }
            ,excelAll: function(){
                //导出Excel
                wk.excelAll(getIds(),$('#layuiForm').serialize(),"{:url('excelAdmin')}");
            }
        };
        $('.layuiBtn').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
        var getIds = function () {
            var ids = [];
            var checkStatus = table.checkStatus('testReload')
                ,data = checkStatus.data;
            $.each(data,function(index,item){
                ids.push(item['id'])
            });
            return ids;
        }
    });
</script>
<!--图片模板-->
<script type="text/html" id="imgTpl">
    <ul onclick="view(this)" id="view_{{d.id}}">
        <li><img data-original="{{d.mechanism_member_img}}" src="{{d.mechanism_member_img}}" class="img-circle table-img" onerror="this.src='/static/admin/images/head_default.gif'"  /></li>
    </ul>
</script>
<!--角色模板-->
<script type="text/html" id="attestationTpl">
    {{# if(d.user_attestation == 3){ }}
        已认证
    {{# } }}
    {{# if(d.user_attestation == 1){ }}
        未认证
    {{# } }}
    {{# if(d.user_attestation == 2){ }}
        认证中
    {{# } }}
    {{# if(d.user_attestation == 4){ }}
        认证失败
    {{# } }}
</script>
<!--状态模板-->
<script type="text/html" id="staBar">
    <input type="hidden" id="zh{{d.user_id}}" value="{{d.user_status}}">
    <input type="checkbox"  id="zt{{d.user_id}}" value="{{d.user_id}}"  lay-skin="switch"  lay-text="ON|OFF" lay-filter="OnOff"{{ d.user_status == 1 ? 'checked' : '' }}  >
</script>
<!--操作模板-->
<script type="text/html" id="opeBar">
    {{# if(d.user_attestation == 3){ }}
    <a href="javascript:location.href = '{:url('uUserAttestation')}?id={{d.user_id}}';" class="btn btn-primary btn-outline btn-xs" title="认证信息"><i class="fa fa-paste"></i></a>&nbsp;
    <a href="javascript:location.href = '{:url('editUserCode')}?id={{d.user_id}}';" class="btn btn-danger btn-outline btn-xs" title="修改志愿者编号"><i class="fa fa-edit"></i></a>
    <a href="javascript:location.href = '{:url('certificate')}?id={{d.user_id}}';" class="btn btn-primary btn-outline btn-xs" title="参与的活动"><i class="fa fa-child"></i></a>
    <a href="javascript:location.href = '{:url('diploma')}?id={{d.user_id}}';" class="btn btn-primary btn-outline btn-xs" title="我的证书"><i class="fa fa-folder"></i></a>

    {{# if(d.is_zyx == 1){ }}

    <a href="javascript:location.href = '{:url('volunteer')}?id={{d.user_id}}';" class="btn btn-primary btn-outline btn-xs" title="添加志愿者之星"><i class="fa fa-user"></i></a>
    {{# } }}
    {{# } }}
    {{# if(d.user_attestation == 2){ }}
    <a href="javascript:location.href = '{:url('uUserAttestation')}?id={{d.user_id}}';" class="btn btn-primary btn-outline btn-xs" title="认证信息"><i class="fa fa-paste"></i></a>
    {{# } }}
    {{# if(d.user_attestation == 4){ }}
    <a href="javascript:location.href = '{:url('uUserAttestation')}?id={{d.user_id}}';" class="btn btn-primary btn-outline btn-xs" title="认证信息"><i class="fa fa-paste"></i></a>
    {{# } }}
    {{# if(d.user_attestation == 1){ }}
    暂无志愿者认证信息
    {{# } }}


    <!--<a href="javascript:wk.confirm('{{d.id}}','{:url('mechanismuserDel')}','single');" class="btn btn-danger btn-outline btn-xs"><i class="fa fa-trash-o"></i> 删除</a>-->
</script>
</body>
</html>